import Vue from "vue";
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from "./App.vue";
import router from "./router";
import store from "./store";
import axios from 'axios'
import qs from 'qs';

import '@/assets/css/index.css'


Vue.config.productionTip = false;

Vue.use(ElementUI);
// axios.defaults.PartField.vue  = true;
Vue.prototype.$axios = axios;
Vue.prototype.$qs = qs;
Vue.prototype.$loading = ElementUI.Loading.service;
Vue.prototype.$msgbox = ElementUI.MessageBox;
Vue.prototype.$alert = ElementUI.MessageBox.alert;
Vue.prototype.$confirm = ElementUI.MessageBox.confirm;
Vue.prototype.$prompt = ElementUI.MessageBox.prompt;
Vue.prototype.$notify = ElementUI.Notification;
Vue.prototype.$message = ElementUI.Message;
//解析浏览器地址拦?后面的参数
Vue.prototype.getLocationParams = (locationParams = location.href.split('?')[1])=>{
  if (locationParams) {
    let arr = locationParams.split('&');
    let obj = {};
    arr.map(v=>{
      let s = v.split('=');
      obj[s[0]] = s[1];
    })

    return obj;
  }
  return ''
}
//把{}全部的true和false转换成1和0
Vue.prototype.replaceAllBoolean = (data)=>{
  data = JSON.stringify(data);
  let reg = new RegExp( 'true' , 'g' );
  let reg2 = new RegExp( 'false' , 'g' );
  data = data.replace(reg, '1');
  data = data.replace(reg2, '0');
  return JSON.parse(data);
}


// axios.defaults.baseURL = 'api/';//代理
// axios.defaults.baseURL = 'http://47.104.80.2:19869';//生产环境
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';//配置请求头

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");
